﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Resources="clr-namespace:WpfRcp.Resources">

    <SolidColorBrush x:Key="TabControlNormalBorderBrush" Color="Yellow" />

    <Style TargetType="{x:Type TabControl}">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="Padding" Value="4,4,4,4" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="BorderBrush" Value="{DynamicResource TabControlNormalBorderBrush}" />
        <Setter Property="Background" Value="{DynamicResource TabControlBackground}" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition x:Name="ColumnDefinition0" />
                            <ColumnDefinition x:Name="ColumnDefinition1" Width="0" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="RowDefinition0" Height="Auto" />
                            <RowDefinition x:Name="RowDefinition1" Height="*" />
                        </Grid.RowDefinitions>
                        <TabPanel Margin="2,2,2,0" x:Name="HeaderPanel" Grid.Column="0" Grid.Row="0" IsItemsHost="true"
                                Panel.ZIndex="1" KeyboardNavigation.TabIndex="1" />
                        <Border x:Name="ContentPanel" Grid.Column="0" Grid.Row="1"
                                Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2"
                                KeyboardNavigation.TabNavigation="Local" CornerRadius="3">
                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                    Margin="{TemplateBinding Padding}" x:Name="PART_SelectedContentHost"
                                    ContentSource="SelectedContent" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="1" />
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0" />
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*" />
                            <Setter Property="Height" TargetName="RowDefinition1" Value="Auto" />
                            <Setter Property="Margin" TargetName="HeaderPanel" Value="2,0,2,2" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0" />
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0" />
                            <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="0" />
                            <Setter Property="Grid.Column" TargetName="ContentPanel" Value="1" />
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto" />
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="*" />
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*" />
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0" />
                            <Setter Property="Margin" TargetName="HeaderPanel" Value="2,2,0,2" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0" />
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0" />
                            <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="1" />
                            <Setter Property="Grid.Column" TargetName="ContentPanel" Value="0" />
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="*" />
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto" />
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*" />
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0" />
                            <Setter Property="Margin" TargetName="HeaderPanel" Value="0,2,2,2" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- TABITEM -->
    <Style TargetType="{x:Type TabItem}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Margin" Value="0,0,3,3" />
        <Setter Property="Foreground" Value="{DynamicResource TabItemForeground}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid>
                        <Border Name="Bd" Background="{DynamicResource TabItemBackground}" BorderThickness="0"
                                CornerRadius="4" MinWidth="100" Margin="{TemplateBinding Margin}">
                            <ContentPresenter x:Name="ContentSite" VerticalAlignment="Center"
                                    HorizontalAlignment="Center" ContentSource="Header" Margin="12,2,12,2" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>

                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource TabItemHotBackground}" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Panel.ZIndex" Value="1" />
                            <Setter TargetName="Bd" Property="Background"
                                    Value="{DynamicResource TabItemSelectedBackground}" />
                        </Trigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!--OVERLAPPING TAB CONTROL-->
    <Style x:Key="OverlappingTabControlStyle" TargetType="{x:Type TabControl}">
        <Setter Property="Foreground" Value="White" />
        <Setter Property="Padding" Value="4" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="#F0F0F0" />
        <Setter Property="Background">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0 0" EndPoint="1 0">
                    <GradientStop Color="#29313B" Offset="0.0" />
                    <GradientStop Color="#29313B" Offset="1.0" />
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="TabStripPlacement" Value="Right" />
        <!--<Setter Property="BitmapEffect">
            <Setter.Value>
                
                <OuterGlowBitmapEffect GlowColor="White" GlowSize="3" />
            </Setter.Value>
        </Setter>-->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <ControlTemplate.Resources>
                        <Resources:AboutBoxBorderConverter x:Key="aboutBoxBorderConverter" />
                    </ControlTemplate.Resources>
                    <Border BorderThickness="0" BorderBrush="#FFED71" CornerRadius="5" SnapsToDevicePixels="False">
                        <Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition x:Name="ColumnDefinition0" Width="260" />
                                <ColumnDefinition x:Name="ColumnDefinition1" Width="*" />
                            </Grid.ColumnDefinitions>
                            <Border x:Name="ContentPanel" Grid.Column="1" Margin="-1 0 0 0"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2"
                                    KeyboardNavigation.TabNavigation="Local"
                                    CornerRadius="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent}, Path=SelectedIndex, Converter={StaticResource aboutBoxBorderConverter}}">
                                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                        Margin="{TemplateBinding Padding}" x:Name="PART_SelectedContentHost"
                                        ContentSource="SelectedContent" />
                            </Border>
                            <TabPanel x:Name="HeaderPanel" Grid.Column="0" IsItemsHost="true"
                                    KeyboardNavigation.TabIndex="1" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <!--<DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent}, Path=SelectedIndex}" Value="0">
                            <Setter TargetName="ContentPanel" Property="CornerRadius" Value="0 5 5 5" />
                        </DataTrigger>-->
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--OVERLAPPING TABITEM -->
    <Style x:Key="OverlappingTabItemStyle" TargetType="{x:Type TabItem}">
        <Style.Resources>
            <LinearGradientBrush x:Key="HotTabStyle" StartPoint="0 0" EndPoint="1 0">
                <GradientStop Color="#57606C" Offset="0.0" />
                <GradientStop Color="#29313B" Offset="1.0" />
            </LinearGradientBrush>

            <LinearGradientBrush x:Key="NormalTabStyle" StartPoint="0 0" EndPoint="1 0">
                <GradientStop Color="#29313B" Offset="0.0" />
                <GradientStop Color="#29313B" Offset="1.0" />
            </LinearGradientBrush>
        </Style.Resources>

        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Margin" Value="0 0 0 3" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="Header" Value="{Binding HeaderInfo}" />
        <!--<Setter Property="BitmapEffect">
            <Setter.Value>
                <OuterGlowBitmapEffect GlowColor="#7B4A1D" GlowSize="4"  />
            </Setter.Value>
        </Setter>-->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Border Name="Bd" Background="Transparent" BorderThickness="1,1,0,1" CornerRadius="5,0,0,5"
                            MinWidth="100" SnapsToDevicePixels="True" Margin="{TemplateBinding Margin}">
                        <ContentPresenter x:Name="ContentSite" VerticalAlignment="Center" HorizontalAlignment="Left"
                                ContentSource="Header" Margin="6,4,6,4" />
                    </Border>
                    <ControlTemplate.Triggers>

                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Bd" Property="Background" Value="{StaticResource HotTabStyle}" />
                            <Setter TargetName="Bd" Property="BorderThickness" Value="1 1 0 1" />
                            <Setter TargetName="Bd" Property="Background" Value="{StaticResource NormalTabStyle}" />
                            <Setter TargetName="Bd" Property="BorderBrush" Value="#F0F0F0" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Panel.ZIndex" Value="1" />
                            <Setter TargetName="Bd" Property="Background" Value="{StaticResource NormalTabStyle}" />
                            <Setter TargetName="Bd" Property="BorderThickness" Value="1 1 0 1" />
                            <Setter TargetName="Bd" Property="Background" Value="{StaticResource NormalTabStyle}" />
                            <Setter TargetName="Bd" Property="BorderBrush" Value="#F0F0F0" />
                        </Trigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>